var paper = [];
$(document).ready(function(e){
	paper[0] = 1;
	$("#add-itemtype").click(function(){
		paper[paper.length] = 1;
		$("#type").append('<div class="list">'
							+'<span class="lab1 select-lab">题型:</span><select name="type'+paper.length+'" class="choose">'
								+'<option>选择</option>'
								+'<option>填空</option>'
								+'<option>问答</option>'
							+'</select>'
							+'<span class="lab1 ans-lab">该题型内总分值</span><input type="text" name="score'+paper.length+'" class="answer-input1" />'
							+'<div class="box">'
								+'<a class="add bor" href="javascript:void(0)" onclick="addItem('+paper.length+')">+</a>'
								+'<div class="box3" id="type'+paper.length+'">'
                                    +'<div class="list1" id="item'+paper.length+'-1">'
                                        +'<span class="lab1 ans-lab">该题目分值</span><input type="text" name="score'+paper.length+'-1" class="answer-input1" /><br />'
                                        +'<span class="lab1 ans-lab">题目循环次数</span><input type="text" name="cyclenum'+paper.length+'-1" class="answer-input1" /><br />'
                                        +'<span class="lab1 ans-lab">难度选择</span><span class="dif"><input type="radio" name="diff'+paper.length+'-1"/>A<input type="radio" name="diff'+paper.length+'-1" />B<input type="radio" name="diff'+paper.length+'-1" />C<input type="radio" name="diff'+paper.length+'-1" />D</span><br />'
                                        +'<span class="lab1 select-lab">学科:</span><select class="choose" name="subject'+paper.length+'-1">'
                                            +'<option>几何</option>'
                                            +'<option>代数</option>'
                                            +'<option>英语</option>'
                                        +'</select><br />'
                                    +'</div>'
								+'</div>'
								+'<a class="add bor" style="display:none;" id="delete-item'+paper.length+'" onclick="deleteItem('+paper.length+')" href="javascript:void(0)" >-</a>'
							+'</div>'
						+'</div>');
		if(paper.length == 2){
			$("#delete-itemtype").show();	
		}
	});
	$("#delete-itemtype").click(function(){
		$("#type"+paper.length).parent().parent().remove();
		paper.length -= 1;
		if(paper.length == 1){
			$(this).hide();	
		}
	});
});

function addItem(num){
	paper[num-1] += 1;
	$("#type"+num).append('<div class="list1" id="list'+num+'-'+paper[num-1]+'">'
                                        +'<span class="lab1 ans-lab">该题目分值</span><input type="text" name="score'+num+'-'+paper[num-1]+'" class="answer-input1" /><br />'
                                        +'<span class="lab1 ans-lab">题目循环次数</span><input type="text" name="cyclenum'+num+'-'+paper[num-1]+'" class="answer-input1" /><br />'
                                        +'<span class="lab1 ans-lab">难度选择</span><span class="dif"><input type="radio" name="diff'+num+'-'+paper[num-1]+'"/>A<input type="radio" name="diff'+num+'-'+paper[num-1]+'" />B<input type="radio" name="diff'+num+'-'+paper[num-1]+'" />C<input type="radio" name="diff'+num+'-'+paper[num-1]+'" />D</span><br />'
                                        +'<span class="lab1 select-lab">学科:</span><select class="choose" name="subject'+num+'-'+paper[num-1]+'">'
                                            +'<option>几何</option>'
                                            +'<option>代数</option>'
                                            +'<option>英语</option>'
                                        +'</select><br />'
                                    +'</div>');
	if(paper[num-1] == 2){
		$("#delete-item"+num).show();
	}
};

function deleteItem(num){
	$("#list"+num+"-"+paper[num-1]).remove();
	paper[num-1] -= 1;
	if(paper[num-1] == 1){
		$("#delete-item"+num).hide();	
	}
};